<!DOCTYPE html>
<html>
{include file="public/head"}

<body>
    {include file="contest/contest-nav"}
    <!-- 分割 -->
    <div class="fly-panel">
        <div class="fly-panel-title">
            <form method="get" action="{:url('web/contest/status?cid=' . $list[0]['contest_id'])}">
                <div class="layui-form" style="text-align: center;">
                    <div class="layui-inline status-input-comb">
                        <select name="pid">
                            <option value="-1">选择题号</option>>
                        <?php 
                            foreach($problem_chr_id as $key => $value) {

                            if(isset($data['problem_id'])&&$data['problem_id'] == $key) {
                            echo '<option value=' . $key . ' selected=""> ' .chr(65 + $value['num']) . ' - ' . $value['alias'] . '</option>';
                            } else {
                            echo '<option value=' . $key . ' > ' . chr(65 + $value['num']) . ' - ' . $value['alias'] . '</option>';
                            }
                        }
                        ?>
                    </select>
                    </div>
                    <div class="layui-inline status-input-comb">
                        <input type="text" name="user_id" placeholder="请输入用户名" class="layui-input {if condition="isset($contest_unmake)"} layui-disabled {/if}"  value="{if condition="(isset($data.user_id))"}{$data.user_id}{/if}"  {if condition="isset($contest_unmake)"} readonly{/if}>
                    </div>
                    <div class="layui-input-inline status-input-comb">
                        <select name="language">
                            <option value="-1">选择语言</option>
                            {foreach $lang as $k=>$v} {if condition="$lang_mask&(1<<$k)"} {if condition="isset($data.language)&&$data.language==$k"} <option value="{$k}" selected="">{$v}</option> {else/} <option value="{$k}" >{$v}</option> {/if} {/if} {/foreach}
                        </select>
                    </div>
                    <div class="layui-input-inline status-input-comb">
                        <select name="result">
                            <option value="-1">选择状态</option>
                            <?php 
                            for($i=4;$i<=13;$i++)
                            {
                                if(isset($data['result'])&&$data['result']==$i){
                                    echo ' <option value="'.$i.'" selected="">'.$resultset[$i].'</option>';
                                }
                                else {
                                    echo ' <option value="'.$i.'" >'.$resultset[$i].'</option>';
                                }
                            }
                            for($i=0;$i<4;$i++)
                            {
                                if(isset($data['result'])&&$data['result']==$i){
                                    echo ' <option value="'.$i.'" selected="">'.$resultset[$i].'</option>';
                                }
                                else {
                                    echo ' <option value="'.$i.'" >'.$resultset[$i].'</option>';
                                }
                            }

                            ?>
                        </select>
                        <div class="layui-unselect layui-form-select">
                        </div>
                    </div>
                    <div class="layui-inline status-input-comb">
                        <button class="layui-btn" type="submit">开始查找</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div  style="margin-left:50px;margin-right:50px;">
        <table class="layui-table" lay-even lay-skin="nob">
            <colgroup>
                <col width="150">
                <col width="200">
                <col width="100">
                <col width="200">
                <col width="100">
                <col width="100">
                <col width="100">
                <col width="200">
            </colgroup>
            <thead>
                <tr class="layui-bg-green">
                    <th>运行号</th>
                    <th>用户</th>
                    <th>题号</th>
                    <th>结果</th>
                    <th>时间</th>
                    <th>内存</th>
                    <th>语言</th>
                    <th>提交时间</th>
                </tr>
            </thead>
            <tbody>
                {foreach name="urldata" item="v"}
                <tr>
                    <td><a class="fly-link fly-joinad" href="{:url('web/Problem/showcode','cid='.$v['solution_id'])}">{$v.solution_id}</a></td>
                    <td><a href="{:url('web/account/info?user_id=' . $v.user_id)}" class="fly-link fly-joinad">{$v.user_id}</a></td>
                    <td><a href="{:url('web/contest/problem?cid='.$list[0]['contest_id'] .'&num=' . chr($v.num+65))}" class="fly-link fly-joinad">{:chr($v.num+65)}</td>
                        <td>
                                    <a href="{:url('web/Problem/showcode','cid='.$v['solution_id'])}" >
                                       <span id='{$v.solution_id}' class="{if condition="$v.result<4"}nyoj-wait{/if}" style="color: {eq name='$v.result' value='4'}#5FB878;{else/}#FF5722{/eq}">
                                          {$resultset[$v.result]}
                                        {if condition="$v.result<4"}
                                            <i  class="layui-icon layui-anim-rotate layui-anim-loop" style="color: black;float: right;">&#xe63d;</i>
                                        {/if}                                      
                                       </span>
                                       
                                    </a>
                                
                                </td>
                         <td id='time-{$v.solution_id}'>{$v.time}ms</td>
                         <td id="mem-{$v.solution_id}">{$v.memory} KB</td>
                        <td><a class="fly-link fly-joinad" href="{:url('web/Problem/showcode','cid='.$v['solution_id'])}">{$lang[$v.language]}</a></td>
                        <td>{$v.in_date}</td>
                    </tr>
                    {/foreach}
                </tbody>
            </table>
            <div style="text-align: center; ">{$page}</div>
        </div>
    </div>
    </div>
    </div>

    {include file="public/foot"}
	{include file="contest/post-notice"}
</body>
<script>
</script>
<script>
    var clocktime;
    function do_something(){
        layui.use(['jquery'],function(){
            var $=layui.jquery;
            var mydata='';
            $('.nyoj-wait').each(function(){
                mydata+=($(this).attr('id')+'_');
            });
            if(mydata==='')
            {
                clearInterval(clocktime);
            }
            $.ajax({
                url:'/api/submit-status-'+mydata,
                success:function(res){
                   //console.log(res);
                    for(var x in res){
                        var i=res[x];
                        //console.log(i);
                        if(i.code===0){
                            if(i.result>4){
                                $('#'+i.solution_id).html(i.result_zh);
                                $('#'+i.solution_id).removeClass('nyoj-wait');
                                $("#time-"+i.solution_id).text(i.time+' ms');
                                $("#mem-"+i.solution_id).html(i.memory+' KB');
                            }
                            else if(i.result===4){
                                $('#'+i.solution_id).html(i.result_zh);
                                $('#'+i.solution_id).css("color","#5FB878");
                                $('#'+i.solution_id).removeClass('nyoj-wait');
                                
                                $("#time-"+i.solution_id).html(i.time+' ms');
                                $("#mem-"+i.solution_id).html(i.memory+' KB');
                            }
                            else 
                            {
                                $('#'+i.solution_id).html(i.result_zh+'<i  class="layui-icon layui-anim-rotate layui-anim-loop" style="color: black;float: right;">&#xe63d;</i>');
                            }
                        }
                    }
                }
            });
        });
    }
    clocktime=setInterval('do_something()',3000);
    setTimeout('clearInterval(clocktime);', 30000);
</script>
</html>